/**
 * 复制内容到剪切板
 * */
import { Modal } from "ant-design-vue";
import { createVNode } from 'vue'
import { QuestionCircleFilled } from "@ant-design/icons-vue";

export function handleCopy (data) {
  try {
    const oInput = document.createElement('input')
    oInput.value = data
    document.body.appendChild(oInput)
    oInput.select()
    document.execCommand('Copy')
    oInput.remove()
    return true
  }catch (e) {
    return false
  }
}

/**
 * 消息确认弹窗，主要是为了统一按钮文字和图标
 * @param options 参照ant-design-vue 中confirm的配置项
 * @constructor
 */
export function BhMessage(options) {
  Modal.confirm({
    icon: createVNode(QuestionCircleFilled),
    wrapClassName: 'bh-modal-confirm',
    content: '默认文字',
    okText: '是',
    okType: 'primary',
    cancelText: '否',
    width: '320px',
    onOk() {
      console.log('OK');
    },
    onCancel() {
      console.log('Cancel');
    },
    ...options
  });
}